#include <iostream>
#include <string>

std::string AddBigNumber(std::string a, std::string b) {

    //a是大数，b是小数
    if (a.size() < b.size()) {
        std::swap(a, b);
    }

    int aLen = a.size();
    int bLen = b.size();

    //准备结果
    //预先分配空间，避免多次扩容
    //分配aLen+1的空间，确保可以容下进位
    std::string result(aLen + 1, '0');

    //b补0对齐
    for (int i = 0; i < aLen - bLen; i++) {
        b.insert(b.begin(), '0');
    }

    //进位
    int carry = 0;

    for (int i = aLen - 1; i >= 0; i--) {
        //转成数字，相加，加上进位
        int num = (a[i] - '0') + (b[i] - '0') + carry;
        //计算进位
        carry = num / 10;
        //计算当前位
        num = num % 10;
        //使用下标操作，时间复杂度O(1)
        //当i=aLen-1的时候，i+1=aLen，result[aLen]是最后一个字符
        result[i + 1] = (char)(num + '0');
    }

    //如果最后有进位，首位就是进位
    if (carry > 0) {
        result[0] = (char)(carry + '0');
        return result;
    }

    //如果没有进位，去掉首位多分配的'0'
    return result.substr(1);
}

/**
 * 大数乘上单个数字
 * @param bigNum 
 * @param digit 
 * @return 
 */
std::string MultiplyByDigit(
    const std::string& bigNum, 
    const int digit) {
	if (digit == 0) {
        return "0";
	}

    std::string result(bigNum.size() + 1, '0');

    int carry = 0;
    for(int i=bigNum.size()-1; i>=0;i--) {
        int num = (bigNum[i] - '0')*digit + carry;

        result[i+1] = (char)(num % 10 + '0');
        carry = num / 10;
    }

    if (carry > 0) {
        result[0] = (char)(carry + '0');
        return result;
    }

    return result.substr(1);
}

std::string MultiplyBigNumber(const std::string& a, const std::string& b) {
	if(a=="0" || b=="0") {
        return "0";
	}

    std::string result = "0";

    int bLen = b.size();

    for(int i=0; i<bLen; i++) {
        int digit = b[bLen - i - 1] - '0';
        std::string temp = MultiplyByDigit(a, digit);
        temp += std::string(i, '0');

        result = AddBigNumber(result, temp);
    }

    return result;

}


/**
 * 
 * NOIP1998 , 阶乘之和
 */
int main() {
    int n;
    std::cin >> n;

    std::string result = "0";
    std::string temp = "1";
    for (int i = 2; i <= n+1; i++) {
        result = AddBigNumber(result, temp);
        temp = MultiplyBigNumber(temp, std::to_string(i));
    }

    std::cout << result;

	return 0;
}
